package com.kaifamiao.www.demo.Do29.am;

public class Person {
}
class Student extends Person{
    String name;
    @Override
    public boolean equals(Object obj){
        if(obj ==null){
            return false;
        }
        if(this == obj){
            return true;
        }
        // 强制类型转换 先判断
        //if(obj instanceof Student){//Student对象，Student子类对象都可以
        if(obj.getClass()==Student.class){//只有student对象才可以
            Student stu = (Student) obj;
            return true;
        }
        return false;
    }
    @Override
    public int hashCode(){
        final int h = 31;
        int result = 0;
        result += h * name.hashCode();

        return result;
    }
}
class BoyStudent extends Student {}

class Teacher extends Person {}

class Boy extends Person {}

class Girl extends Person {}
